package com.medvalley.tcm.controller;

import com.medvalley.tcm.base.Result;
import com.medvalley.tcm.cache.RedisCache;
import com.medvalley.tcm.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/system")
@Api("系统相关")
public class SystemController extends BaseController {

    @Autowired
    private RedisCache redisCache;

    @GetMapping("/version")
    @ApiOperation("系统版本，是否显示隐私政策")
    public Result getVersion() {
        Map<String, String> resultData = new HashMap<>(3);
        String systemVersion = redisCache.getValue("system_version");
        if (StringUtils.isEmpty(systemVersion)) {
            systemVersion = "0";
        }
        resultData.put("systemVersion", systemVersion);
        return success(resultData);
    }
}
